</Placemark>
<Placemark>
<name>NOTE 1</name>
- <description>12 test lines - see notes with GPX sample!!\rfour line widths for solid red\rtwo line widths for dashed red\rseven colors for medium width\rNote that line names have nothing at all to do with line style attributes!\vThese are named for convenient cross-reference,\r but keep in mind that "red med" is a line label and "Red Medium" is a style label.\rWaypoints are generated by Topo to exactly match the first track point.\rApparently only GPX and KML output from GPSBabel retain track descriptions??</description>
+ <description>12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions??</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.277670,37.522060</coordinates>
</Placemark>
<Placemark>
<name>NOTE 2</name>
- <description>how GPX from GPSBabel shows Topo track desc as of 2012:\r(line name and line style are NOT related to actual color or width)\r\r<trk>\r <name>red line</name>\r <desc>Style=red med, Width=3, Dashed=0, Color=#ff0000</desc>\r<number>1</number>\r<trkseg>\r...\r(Topo menu colors are stored in the file as web-style hex RGB)\r Red=#ff0000, Yellow=#ffff00, Green=#008000, Blue=#000080,\r Purple=#800080, Black=#000000, White=#ffffff\r(Topo solid line widths: Hairline=1, Thin=2, Medium=3, Thick=4)\r(Topo dashed line widths: Hairline=1, Thin=2)\rSRE's tpo.c mod stuffs Style/Width/Dashed/Color fields into "desc" field\r under the assumption that something will post-process GPX or KML output\r and move information from desc to private extensions\r(solid lines have "Dashed=0", can have width of 1=hairline to 4=thick)\r(dashed lines have "Dashed=1", can only have width of 1=hairline or 2=thin)\r</description>
+ <description>how GPX from GPSBabel shows Topo track desc as of 2012: (line name and line style are NOT related to actual color or width) <trk> <name>red line</name> <desc>Style=red med, Width=3, Dashed=0, Color=#ff0000</desc> <number>1</number> <trkseg> ... (Topo menu colors are stored in the file as web-style hex RGB) Red=#ff0000, Yellow=#ffff00, Green=#008000, Blue=#000080, Purple=#800080, Black=#000000, White=#ffffff (Topo solid line widths: Hairline=1, Thin=2, Medium=3, Thick=4) (Topo dashed line widths: Hairline=1, Thin=2) SRE's tpo.c mod stuffs Style/Width/Dashed/Color fields into "desc" field under the assumption that something will post-process GPX or KML output and move information from desc to private extensions (solid lines have "Dashed=0", can have width of 1=hairline to 4=thick) (dashed lines have "Dashed=1", can only have width of 1=hairline or 2=thin) </description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.284910,37.522349</coordinates>
</Placemark>
<Placemark>
<name>NOTE 3</name>
- <description>how KML from GPSBabel shows Topo track desc as of 2012:\r(see important notes with GPX sample, all of them apply here!)\r(note that GPSBabel forces all track styles to be the same - why?)\r\r <Folder>\r <name>Tracks</name>\r <Folder>\r <name>red line</name>\r <snippet/>\r <description>\r<![CDATA[<table>\r <tr><td><b>Description</b> Style=Red Medium, Width=3, Dashed=0, Color=#ff0000 </td></tr>\r <tr><td><b>Distance</b> 1.3 mi </td></tr>\r </table>]]>\r </description>\r <Folder>\r <name>Points</name>\r <Placemark>\r <name>red line-0</name>\r...</description>
+ <description>how KML from GPSBabel shows Topo track desc as of 2012: (see important notes with GPX sample, all of them apply here!) (note that GPSBabel forces all track styles to be the same - why?) <Folder> <name>Tracks</name> <Folder> <name>red line</name> <snippet/> <description> <![CDATA[<table> <tr><td><b>Description</b> Style=Red Medium, Width=3, Dashed=0, Color=#ff0000 </td></tr> <tr><td><b>Distance</b> 1.3 mi </td></tr> </table>]]> </description> <Folder> <name>Points</name> <Placemark> <name>red line-0</name> ...</description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.288962,37.522691</coordinates>
</Placemark>
<Placemark>
<name>NOTE 4</name>
- <description>how MapSource 6.16.3 adds color to a track as of 2012:\r(color choices are Dark Gray, Red, Green, Yellow, Blue, Magenta, Cyan, White, Transparent)\r(should be easy to turn desc tag into their extension, but better to directly write track styles)\r\r <trk>\r <name>Hwy 50 from Placerville</name>\r <extensions>\r <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">\r <gpxx:DisplayColor>Red</gpxx:DisplayColor>\r </gpxx:TrackExtension>\r </extensions>\r <trkseg>\r...\r</description>
+ <description>how MapSource 6.16.3 adds color to a track as of 2012: (color choices are Dark Gray, Red, Green, Yellow, Blue, Magenta, Cyan, White, Transparent) (should be easy to turn desc tag into their extension, but better to directly write track styles) <trk> <name>Hwy 50 from Placerville</name> <extensions> <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"> <gpxx:DisplayColor>Red</gpxx:DisplayColor> </gpxx:TrackExtension> </extensions> <trkseg> ... </description>
<styleUrl>#waypoint</styleUrl>
<Point>
<coordinates>-122.272938,37.522105</coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff0000ff</color>
+ <width>4</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff00ffff</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff800000</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff000000</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff0000ff</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff0000ff</color>
+ <width>2</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff0000ff</color>
+ <width>1</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>500000ff</color>
+ <width>2</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>500000ff</color>
+ <width>1</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff008000</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ff800080</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
<Placemark>
<name>Path</name>
<styleUrl>#lineStyle</styleUrl>
+ <Style>
+ <LineStyle>
+ <color>ffffffff</color>
+ <width>3</width>
+ </LineStyle>
+ </Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
{
unsigned int track_count, track_style_count;
unsigned int xx,ii,tmp;
+#define TRACKNAMELENGTH 256
int DEBUG=0;
if (DEBUG) {
printf("Unpacking %d track styles...\n",track_style_count);
}
- char style_name[track_style_count][256]; // some huge value
- char style_color[track_style_count][7]; // web color is 6 chars
+ char style_name[track_style_count][TRACKNAMELENGTH]; // some huge value
+ int style_color[track_style_count][3]; // keep R/G/B values separate because line_color needs BGR
int style_wide[track_style_count],style_dash[track_style_count];
for (ii = 0; ii < track_style_count; ii++) {
- style_color[ii][0] = '\0';
// clumsy way to skip two undefined bytes
for (xx = 0; xx < 2; xx++) {
}
// next three bytes are RGB color, fourth is unknown
+ // Topo and web uses rrggbb, also need line_color.bbggrr for KML
for (xx = 0; xx < 3; xx++) {
- tmp = (unsigned char) gbfgetc(tpo_file_in);
- sprintf(style_color[ii], "%s%02x",style_color[ii],tmp);
+ style_color[ii][xx] = (int) gbfgetc(tpo_file_in);
+ if((style_color[ii][xx] < 0) || (style_color[ii][xx] >255)) {
+ style_color[ii][xx] = 0; // assign black if out of range 0x00 to 0xff
+ // used to store strings: sprintf(style_color[ii], "%s%02x",style_color[ii],tmp);
+ }
}
tmp = (unsigned char) gbfgetc(tpo_file_in);
- // printf("Skipping unknown byte 0x%x after color=%s\n",tmp,style_color);
+ // printf("Skipping unknown byte 0x%x after color\n",tmp);
// byte for name length, then name
tmp = (unsigned char) gbfgetc(tpo_file_in);
// wrong byte order?? tmp = tpo_read_int(); // 16 bit value
// printf("Track %d has %d-byte (0x%x) name\n",ii,tmp,tmp);
- if (tmp >= 256) {
- printf("ERROR! Found track style over 128 chars, skipping tracks\n");
+ if (tmp >= TRACKNAMELENGTH) {
+ printf("ERROR! Found track style over TRACKNAMELENGTH chars, skipping all tracks!\n");
return;
}
if (tmp) {
}
if (DEBUG) {
- printf("Track style %d: color=#%s, width=%d, dashed=%d, name=%s\n",ii,style_color[ii],style_wide[ii],style_dash[ii],style_name[ii]);
+ printf("Track style %d: color=#%02x%02x%02x, width=%d, dashed=%d, name=%s\n",ii,style_color[ii][0],style_color[ii][1],style_color[ii][2],style_wide[ii],style_dash[ii],style_name[ii]);
}
}
int lon = 0;
unsigned int jj;
route_head* track_temp;
-
+ char rgb[7],bgr[7];
+ int bbggrr = 0;
// Allocate the track struct
track_temp = route_head_alloc();
track_style = tpo_read_int(); // index into freehand route styles defined in this .tpo file
track_style -= 1; // STARTS AT 1, whereas style arrays start at 0
- // Can be 8/16/32-bit value
+ // Can be 8/16/32-bit value - never used?
track_length = tpo_read_int();
//UNKNOWN DATA LENGTH
xasprintf(&track_name, "TRK %d", ii+1);
}
track_temp->rte_name = track_name;
+
+ // RGB line_color expressed for html=rrggbb and kml=bbggrr - not assigned before 2012
+ sprintf(rgb,"%02x%02x%02x",style_color[track_style][0],style_color[track_style][1],style_color[track_style][2]);
+ sprintf(bgr,"%02x%02x%02x",style_color[track_style][2],style_color[track_style][1],style_color[track_style][0]);
+ sscanf(bgr,"%06x",&bbggrr); // hex string to integer - probably not the best way to do style_color to bbggrr
+ track_temp->line_color.bbggrr = bbggrr;
+
+ // track texture (dashed=1, solid=0) mapped into opacity - not assigned before 2012
+ track_temp->line_color.opacity = 0xff; // 255
+ if(style_dash[track_style]) {
+ track_temp->line_color.opacity = 0x50;
+ }
+
+ // track width, from 1=hairline to 4=thick in Topo - not assigned before 2012
+ // (what are correct values for KML or other outputs??)
+ track_temp->line_width = style_wide[track_style];
+
if (DEBUG) printf("Track Name: %s, ?Type?: %d, Style Name: %s, Width: %d, Dashed: %d, Color: #%s\n",
- track_name, line_type, style_name[track_style], style_wide[track_style], style_dash[track_style], style_color[track_style]);
+ track_name, line_type, style_name[track_style], style_wide[track_style], style_dash[track_style],rgb);
// Track description
// track_temp->rte_desc = NULL; // pre-2012 default, next line from SRE saves track style as track description
xasprintf(&track_temp->rte_desc, "Style=%s, Width=%d, Dashed=%d, Color=#%s",
- style_name[track_style], style_wide[track_style], style_dash[track_style], style_color[track_style]);
+ style_name[track_style], style_wide[track_style], style_dash[track_style], rgb);
// Route number
track_temp->rte_num = ii+1;